package com.audaque.springboot.foshanupload.web.webdemo.mapper;

import com.audaque.springboot.foshanupload.web.webdemo.mapper.covert.TypeCoverter;
import com.audaque.springboot.foshanupload.web.webdemo.model.domain.BasicEntity;
import com.audaque.springboot.foshanupload.web.webdemo.model.domain.Car;
import com.audaque.springboot.foshanupload.web.webdemo.model.domain.Person;
import com.audaque.springboot.foshanupload.web.webdemo.model.dto.CarDto;
import com.audaque.springboot.foshanupload.web.webdemo.model.dto.PersonDTO;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;


@Mapper

public interface PersonMapper {

    PersonMapper INSTANCT = Mappers.getMapper(PersonMapper.class);

    @Mapping(target = "fatherName",  constant = "hollis")
    @Mapping(target = "age",source = "age", numberFormat = "#0.00")
    @Mapping(target = "country", source = "personCountry")
    @Mapping(target = "createTime",expression = "java(new java.util.Date())", dateFormat = "yyyy-MM-dd")
    @Mapping(target = "describe", source = "describe", defaultValue = "默认值")
    @Mapping(target = "personName", source = "name")
    @Mapping(target = "id", ignore = true) // 忽略id，不进行映射
    PersonDTO conver(Person person);
    @Mapping(target = "createTime",source = "basicEntity.createTime")
    PersonDTO combinationConver(Person personC, BasicEntity basicEntity);


    @Mapping(target = "id", source = "id")
    PersonDTO mapTo(Person person, String id);


    /**
     * 方法应继承相应反向方法的反向配置
     * @param dto
     * @return
     */

    @InheritInverseConfiguration
    Person conver(PersonDTO dto);


}
